##############################################################################
Replication of “Campaigns and the Selection of Policy-seeking Representatives"
(Shaun Bowler, Gail McElroy, Stefan Müller)
##############################################################################


## Information on the Replication Material

First, create a new RProj. file in the main folder. 
Afterwards, run the scripts described below to reproduce the results in chronological order. 
Note that you need access to the survey data to merge the files. 
If you have access, add the files to the folder of the respective legislative cycle.


## Description of files 

* 01a_prepare_data_ep_2004-2009.R: merges data for the 6th European Parliament

* 01b_create_data_ep_2009-2014.R: merges data for the 7th European Parliament

* 01c_prepare_data_dail_2007-2011.R: merges data for the 30th Dáil (Ireland)

* 01d_prepare_data_dail_2011-2016.R: merges data for the 31st Dáil (Ireland)

* 01e_prepare_data_bundestag_2005-2009.R: merges data for the 16th Bundestag (Germany)

* 02_analysis.R: reproduce all analyses from the paper and the Online Supplementary Material. Note that the data for the Comparative Candidates Survey (Modules 1 and 2) must be requested from FORS (http://www.comparativecandidates.org/). Therefore, the datasets are not included in the replication material.



The scripts were executed successfully with the following versions of the required packages (2019-09-19):
> sessionInfo()R version 3.6.0 (2019-04-26)Platform: x86_64-apple-darwin15.6.0 (64-bit)Running under: macOS Mojave 10.14.6Matrix products: defaultBLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylibLAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dyliblocale:[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8attached base packages:[1] stats     graphics  grDevices utils     datasets  methods   base     other attached packages: [1] forcats_0.4.0     stringr_1.4.0     dplyr_0.8.1       purrr_0.3.2       [5] readr_1.3.1       tidyr_0.8.3       tibble_2.1.3      tidyverse_1.2.1   [9] lme4_1.1-21       Matrix_1.2-17     effects_4.1-0     gridExtra_2.3    [13] dotwhisker_0.5.0  Hmisc_4.2-0       ggplot2_3.2.1     Formula_1.2-3    [17] survival_2.44-1.1 lattice_0.20-38   MASS_7.3-51.4     car_3.0-2        [21] carData_3.0-2     texreg_1.36.23    cowplot_1.0.0    loaded via a namespace (and not attached): [1] httr_1.4.0          jsonlite_1.6        splines_3.6.0       [4] modelr_0.1.4        assertthat_0.2.1    latticeExtra_0.6-28 [7] ggstance_0.3.1      cellranger_1.1.0    pillar_1.4.2       [10] backports_1.1.4     glue_1.3.1          digest_0.6.20      [13] RColorBrewer_1.1-2  checkmate_1.9.3     rvest_0.3.3        [16] minqa_1.2.4         colorspace_1.4-1    htmltools_0.3.6    [19] survey_3.36         pkgconfig_2.0.2     broom_0.5.2        [22] haven_2.1.0         scales_1.0.0        openxlsx_4.1.0     [25] rio_0.5.16          htmlTable_1.13.1    generics_0.0.2     [28] withr_2.1.2         nnet_7.3-12         lazyeval_0.2.2     [31] cli_1.1.0           magrittr_1.5        crayon_1.3.4       [34] readxl_1.3.1        nlme_3.1-139        xml2_1.2.2         [37] foreign_0.8-71      tools_3.6.0         data.table_1.12.2  [40] hms_0.4.2           mitools_2.4         munsell_0.5.0      [43] cluster_2.0.8       zip_2.0.1           compiler_3.6.0     [46] rlang_0.4.0         grid_3.6.0          nloptr_1.2.1       [49] rstudioapi_0.10     htmlwidgets_1.3     base64enc_0.1-3    [52] boot_1.3-22         gtable_0.3.0        abind_1.4-5        [55] DBI_1.0.0           curl_3.3            R6_2.4.0           [58] lubridate_1.7.4     knitr_1.22          stringi_1.4.3      [61] Rcpp_1.0.2          rpart_4.1-15        acepack_1.4.1      [64] tidyselect_0.2.5    xfun_0.6 